import Vue from "vue";

//  注册登录 login：
// ID:8f5d2bd6d552608c5151d2f44a8dde8c
// KEY:24bee1ff9d1b73342b7ba5e9f874ad28
// 下单支付 order: 0元抽签、优先购、邀请助力，极验用下单的
// 070f252fea5edcaf228e694aeb1374b5
// 17e7373f1feed42baf302030a1df31e9
// 实名认证: cert
// 045b4c009b64f1d4761a623daac68f20
// 4700a56e170002b0bc609fe67170c92d
// 支付密码  update
// b2db142ce14ff4cd0a31c648ad7c78d1
// 转赠  give
// 76f23cd521fc4829031e23e8aecb887a
// 合成  synthesis
//id:ecc8f8ebdd8c431e1ef0b56ef5200a32
//key:17f298031b1429215416b2f1cf64ffaa 

// 极验
function polarTest(param, callback) {
	console.log("param-------", param);
	let captchId = "";
	if (param) {
		switch (param) {
			case "login":
				captchId = "8f5d2bd6d552608c5151d2f44a8dde8c";
				break;
			case "order":
				captchId = "070f252fea5edcaf228e694aeb1374b5";
				break;
			case "cert":
				captchId = "045b4c009b64f1d4761a623daac68f20";
				break;
			case "update":
				captchId = "b2db142ce14ff4cd0a31c648ad7c78d1";
				break;
			case "give":
				captchId = "76f23cd521fc4829031e23e8aecb887a";
				break;
			case "synthesis":
				captchId = "ecc8f8ebdd8c431e1ef0b56ef5200a32";
				break;
			case "service":
				captchId = "be757ed24b4047eb4afecc7124776c5a";
				break;
			default:
				break;
		}
	}

  Vue.prototype.initGeetest4(
    {
      captchaId: captchId,
      product: "popup",
      language: "zho",
      riskType: "match",
      product: "bind",
    },

    function (captchaObj) {
      //显示验证码
      captchaObj.showCaptcha();
      // 这里可以调用验证实例 captchaObj 的实例方法
      captchaObj.onSuccess(() => {
        //这里是滑动完毕回调
        //通过这个captchaObj.getValidate()方法，会得到一个自定义对象，这个对象里面有三个数据，将来点击提交按钮的时候，不仅仅要提交用户名和密码，还要将这三个数据提交给后端进行验证
        let result = captchaObj.getValidate();
        uni.setStorageSync("payment", true);
        let smsverification = {
          captchaOutput: result.captcha_output,
          lotNumber: result.lot_number,
          genTime: result.gen_time,
          passToken: result.pass_token,
        };
        callback(smsverification);
      });
    }
  );
}

module.exports = {
  polarTest,
};
